package nav;

import java.util.ArrayList;


public class CoordinateCollectionImpl implements ICollection{

	ArrayList<CoordinateTopologyObjectImpl> coordinates = new ArrayList<CoordinateTopologyObjectImpl>();

	public double top = Double.MIN_VALUE;
	public double bottom = Double.MAX_VALUE;
	public double left = Double.NEGATIVE_INFINITY;
	public double right = Double.POSITIVE_INFINITY;
	
	public CoordinateCollectionImpl(){
        
    }

    public void add(Object o) {
    	
        coordinates.add((CoordinateTopologyObjectImpl)o);
        if(((CoordinateTopologyObjectImpl)o).getY()>top)
        	top = ((CoordinateTopologyObjectImpl)o).getY();
        if(((CoordinateTopologyObjectImpl)o).getY()<bottom)
        	bottom = ((CoordinateTopologyObjectImpl)o).getY();
        if(((CoordinateTopologyObjectImpl)o).getX()>left)
        	left = ((CoordinateTopologyObjectImpl)o).getX();
        if(((CoordinateTopologyObjectImpl)o).getX()<right)
        	right = ((CoordinateTopologyObjectImpl)o).getX();
    }

    public void read(String source) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String write() {
        throw new UnsupportedOperationException("Not supported yet.");
    }


    
    
    public ArrayList<CoordinateTopologyObjectImpl> getAll(){
    	return coordinates;
    }
    
    public CoordinateTopologyObjectImpl get(int i){
    	return coordinates.get(i);
    }
}
